package com.ruoyi.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.BasisFrequencyConverterType;
import com.ruoyi.service.IBasisFrequencyConverterTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 变频器类型Controller
 * 
 * @author wangzebing
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/converterType")
public class BasisFrequencyConverterTypeController extends BaseController
{
    @Autowired
    private IBasisFrequencyConverterTypeService basisFrequencyConverterTypeService;

    /**
     * 查询变频器类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisFrequencyConverterType basisFrequencyConverterType)
    {
        startPage();
        List<BasisFrequencyConverterType> list = basisFrequencyConverterTypeService.selectBasisFrequencyConverterTypeList(basisFrequencyConverterType);
        return getDataTable(list);
    }

    /**
     * 导出变频器类型列表
     */
    @Log(title = "变频器类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisFrequencyConverterType basisFrequencyConverterType)
    {
        List<BasisFrequencyConverterType> list = basisFrequencyConverterTypeService.selectBasisFrequencyConverterTypeList(basisFrequencyConverterType);
        ExcelUtil<BasisFrequencyConverterType> util = new ExcelUtil<BasisFrequencyConverterType>(BasisFrequencyConverterType.class);
        util.exportExcel(response, list, "变频器类型数据");
    }

    /**
     * 获取变频器类型详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basisFrequencyConverterTypeService.selectBasisFrequencyConverterTypeById(id));
    }

    /**
     * 新增变频器类型
     */
    @Log(title = "变频器类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisFrequencyConverterType basisFrequencyConverterType)
    {
        return toAjax(basisFrequencyConverterTypeService.insertBasisFrequencyConverterType(basisFrequencyConverterType));
    }

    /**
     * 修改变频器类型
     */
    @Log(title = "变频器类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisFrequencyConverterType basisFrequencyConverterType)
    {
        return toAjax(basisFrequencyConverterTypeService.updateBasisFrequencyConverterType(basisFrequencyConverterType));
    }

    /**
     * 删除变频器类型
     */
    @Log(title = "变频器类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basisFrequencyConverterTypeService.deleteBasisFrequencyConverterTypeByIds(ids));
    }


    @GetMapping("/findAllConverterType")
    public AjaxResult findAll()
    {
        List<BasisFrequencyConverterType> list = basisFrequencyConverterTypeService.findAll();
        return success(list);
    }
}
